import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2022-07-29
 * Time:1:24
 */

class Message{
    public int aa;
    public int bb;
}
@WebServlet("/getPost2")
public class getPost2 extends HelloServlet{
//    创建一个Jackson的核心对象
    private ObjectMapper objectMapper = new ObjectMapper();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        Message message = objectMapper.readValue(req.getInputStream(),Message.class);
        resp.getWriter().write("aa:" + message.aa + ",bb:" + message.bb);
    }
}
